package com.ruoyi.web.controller.app.controller;

import com.ruoyi.framework.web.exception.base.XResult;
import com.ruoyi.sj.domain.Label;
import com.ruoyi.web.controller.app.service.AppLabelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AppLabelController
 * @Description TODO
 * @Author tyc@yanyu
 * @Date 2018/12/29 0029 16:59
 **/
@RestController
@RequestMapping("/app/label")
@Api(tags = "标签")
public class AppLabelController {
    @Autowired
    private AppLabelService appLabelService;

    /**
     * 新增标签
     * @param label
     * @return
     */
    @RequestMapping(value = "addLabel", method = RequestMethod.POST)
    @ApiOperation(value = "新增朋友圈标签", position = 1,response = Label.class,notes = "新增标签")
    public XResult addLabel(Label label) {

        return new XResult("发布成功",appLabelService.insertLabel(label) );
    }

    /**
     * 查询标签列表
     * @param memberId
     * @return
     */
    @RequestMapping(value = "queryList", method = RequestMethod.POST)
    @ApiOperation(value = "查询标签列表", position = 2,response = Label.class,notes = "查询标签列表")
    @ApiImplicitParam(name = "memberId", value = "用户ID号", required = true, dataType = "String", paramType = "query")
    public XResult queryList(String memberId) {

        return new XResult("发布成功",appLabelService.selectLabelList(memberId));
    }

    /**
     * 修改标签
     * @param id
     * @return
     */
    @RequestMapping(value = "updateLabel", method = RequestMethod.POST)
    @ApiOperation(value = "修改标签", position = 3,notes = "修改标签")
    @ApiImplicitParam(name = "id", value = "标签id", required = true, dataType = "String", paramType = "query")
    public XResult updateLabel(Long id,String title) {

        return new XResult("发布成功",appLabelService.updateLabelById(id,title));
    }

    /**
     * 修改标签
     * @param id
     * @return
     */
    @RequestMapping(value = "deleteLabelById", method = RequestMethod.POST)
    @ApiOperation(value = "删除标签", position = 4,notes = "删除标签")
    @ApiImplicitParam(name = "id", value = "标签id", required = true, dataType = "String", paramType = "query")
    public XResult deleteLabelById(Long id) {

        return new XResult("发布成功",appLabelService.deleteLabel(id));
    }

    /**
     * 添加用户
     * @return
     */
    @PostMapping("insertUsers")
    @ApiOperation(value = "标签添加用户")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "标签id", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "IMId", value = "用户id", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "friendsUserId", value = "朋友ID", required = true, dataType = "String", paramType = "query")
    })
    public XResult insertUsers(String ids,String userId,String friendsUserId){
        return new XResult("操作成功",appLabelService.insertUsers(ids,userId,friendsUserId));
    }
}
